package de.lianowar.rolplayambiente.soap;

import java.io.IOException;
import java.util.Properties;

import org.ksoap2.SoapEnvelope;
import org.ksoap2.serialization.SoapObject;
import org.ksoap2.serialization.SoapSerializationEnvelope;
import org.ksoap2.transport.AndroidHttpTransport;
import org.xmlpull.v1.XmlPullParserException;

import android.content.SharedPreferences;

import de.lianowar.rolplayambiente.RolplayAmbienteActivity;

public class SoapConnection {

	private  SharedPreferences.Editor editor;
    private static final String SOAP_ACTION = "\"http://soap.soundcontrol/SoundControlSoap\"";
    private static String METHOD_NAME = "";
    private static final String NAMESPACE = "http://soap.soundcontrol/";
    private  String URL = "";
	private  AndroidHttpTransport httpTransport = null;
	private SoapObject request = null;
	public SoapConnection(String ip,String method)
	{
	
		 String test = ip;
         URL = "http://"+test+":1337/soundcontrol";
         
		 request  = new SoapObject(NAMESPACE, METHOD_NAME);
		
	}
	
	public void doRequest(String message, String method)
	{
			try 
			{
				METHOD_NAME = method;
				request.addProperty("arg0",message); //variable name, value. I got the variable name, from the wsdl file!
		        SoapSerializationEnvelope envelope = new SoapSerializationEnvelope(SoapEnvelope.VER10); //put all required data into a soap envelope
		        envelope.setOutputSoapObject(request);  //prepare request
		        httpTransport = new AndroidHttpTransport(URL);  
		        httpTransport.debug = true; 
		        httpTransport.call(SOAP_ACTION, envelope);
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (XmlPullParserException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
	}
	
}
